From e4f9aa0882653f2372c93d7aeceee57fd296cf94 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Thu, 5 May 2016 18:40:47 -0400 Subject: [PATCH] Turn `url_ref` utility function into method. --- src/cargo/core/source.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index 2229c33bb..0bef76dba 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -137,7 +137,7 @@ impl SourceId { SourceIdInner { kind: Kind::Git(ref reference), ref url, ref precise, .. } => { - let ref_str = url_ref(reference); + let ref_str = reference.url_ref(); let precise_str = if precise.is_some() { format!("#{}", precise.as_ref().unwrap()) @@ -280,7 +280,7 @@ impl fmt::Display for SourceId { } SourceIdInner { kind: Kind::Git(ref reference), ref url, ref precise, .. } => { - try!(write!(f, "{}{}", url, url_ref(reference))); + try!(write!(f, "{}{}", url, reference.url_ref())); if let Some(ref s) = *precise { let len = cmp::min(s.len(), 8); @@ -353,13 +353,6 @@ impl hash::Hash for SourceId { } } -fn url_ref(r: &GitReference) -> String { - match r.to_ref_string() { - None => "".to_string(), - Some(s) => format!("?{}", s), - } -} - impl GitReference { pub fn to_ref_string(&self) -> Option { match *self { @@ -374,6 +367,13 @@ impl GitReference { GitReference::Rev(ref s) => Some(format!("rev={}", s)), } } + + fn url_ref(&self) -> String { + match self.to_ref_string() { + None => "".to_string(), + Some(s) => format!("?{}", s), + } + } } pub struct SourceMap<'src> { -- 2.30.2